package com.xumz.dao.impl;

import java.util.List;

import com.xumz.dao.RecordDao;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;
import com.xumz.model.Record;
import com.xumz.model.RecordManage;

@Repository
public class RecordDaoImpl extends SqlSessionDaoSupport implements RecordDao {
	@Override
	public int insertOne(Record record) {
		return this.getSqlSession().insert(this.getClass().getName() + ".addOne",record);
	}

	@Override
	public List<Record> selectAll() {	
		List<Record> list=this.getSqlSession().selectList("findAll");
		return  list;
	}

	@Override
	public int deleteOne(String id) {
		return this.getSqlSession().delete(this.getClass().getName() + ".recordDeleteById", id);
	}

	@Override
	public List<RecordManage> selectAllRecordManage() {
		return this.getSqlSession().selectList("findAllRecordManage");
	}
	
	@Override
	public List<RecordManage> selectAllRecordManage(String num) {
		if (num.equals("1")){
			return this.getSqlSession().selectList("findAllRecordManage");
		} 
		else if (num.equals("2")){
			return this.getSqlSession().selectList("findAllRecordManageRead");
		}
		else if (num.equals("3")){
			return this.getSqlSession().selectList("findAllRecordManageComment");
		}
		else if (num.equals("4")){
			return this.getSqlSession().selectList("findAllRecordManageBlogname");
		}
		else if (num.equals("5")){
			return this.getSqlSession().selectList("findAllRecordManageStuname");
		}
		return this.getSqlSession().selectList("findAllRecordManage");
	}

	@Override
	public List<RecordManage> selectAllRecordManageByTeacherId(String id) {
		List<RecordManage> list=this.getSqlSession().selectList("findAllRecordByTeacherId",id);
		return list;
	}

}
